import {
	createBrowserRouter,
	// createHashRouter
} from 'react-router-dom'
import Login from '../pages/Login/index.jsx'
import Article from '../pages/Article/index.jsx'
import Layout from '../Layout/index.jsx'
import Board from '../pages/Board/index.jsx'
import About from '../pages/About/index.jsx'
import NotFound from '../pages/NotFound/index.jsx'

// 路由配置
const routes = [
	{
		path: '/',
		element: <Layout />,
		children: [
			{
				// path: 'board',
				index: true, // 默认展示的子路由，现在 '/' 这个路由是 Board 组件的地址。
				element: <Board />,
			},
			{
				path: 'about',
				element: <About />,
			},
		],
	},
	{
		path: '/login',
		element: <Login />,
	},
	{
		// path: '/article',
		path: '/article/:id/:name', // Params传参
		element: <Article />,
	},
	{
		path: '*',
		element: <NotFound />,
	},
]

// 创建路由实例
const router = createBrowserRouter(routes)

export default router
